package com.lzy.crm.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.lzy.crm.base.mybatis.BaseMapper;
import com.lzy.crm.base.mybatis.Example;
import com.lzy.crm.base.service.BaseServiceImpl;
import com.lzy.crm.dao.CreateRoomInfoMapper;
import com.lzy.crm.dao.criteria.CreateRoomInfoCriteria;
import com.lzy.crm.domain.CreateRoomInfo;
import com.lzy.crm.service.CreateRoomInfoService;

@Service("createRoomInfoService")
public class CreateRoomInfoServiceImpl  extends BaseServiceImpl<CreateRoomInfo, CreateRoomInfoCriteria> implements CreateRoomInfoService{

	@Resource
	private CreateRoomInfoMapper createRoomInfoMapper;
	
	@Override
	public BaseMapper<CreateRoomInfo, CreateRoomInfoCriteria> getBaseMapper() {
		return createRoomInfoMapper;
	}

	/**
	 * 查询群信息
	 * @param crowdId
	 * @return
	 */
	public List<CreateRoomInfo> createRoomInfoList(String crowdId){
		Example<CreateRoomInfoCriteria> example = new Example<CreateRoomInfoCriteria>(CreateRoomInfoCriteria.class);
		CreateRoomInfoCriteria createRoomInfoCriteria = example.createCriteria();
		createRoomInfoCriteria.andCrowdIdEqualTo(crowdId);
		example.setOrderByClause(new String[][]{{"roomnumber"}});
		return createRoomInfoMapper.getListByExample(example);
	}
	
	
	/**
	 * 查询房间信息
	 * @param crowdId
	 * @return
	 */
	public CreateRoomInfo createRoomInfoByUid(String uid){
		Example<CreateRoomInfoCriteria> example = new Example<CreateRoomInfoCriteria>(CreateRoomInfoCriteria.class);
		CreateRoomInfoCriteria createRoomInfoCriteria = example.createCriteria();
		createRoomInfoCriteria.andUidEqualTo(uid);
		List<CreateRoomInfo> createRoomInfoList = createRoomInfoMapper.getListByExample(example);
		return createRoomInfoList.size()>0?createRoomInfoList.get(0):null;
	}
	
	/**
	 * 获取牌圈房间数
	 * @param crowdId
	 * @return
	 */
	public Integer getCrowdRoomCount(String crowdId){
		return createRoomInfoMapper.getCrowdRoomCount(crowdId);
	}
	
	
}
